<template>
  <div v-if="total === 0" class="emptyData">
    <img src="@/assets/images/nodata.png" alt="" />
  </div>
  <MarketDemand
    v-else
    columnName="columnName"
    time="publishDate"
    :tableList="tableList"
    @detailClick="detailClick"
    :total="total"
    @pageChange="pageChange"
  ></MarketDemand>
</template>

<script>
import MarketDemand from '@/components/common/MarketDemand'
import { getNavBrandList } from '@/api/dataNavigation'
import { mapGetters } from 'vuex'
import FrontMixins from '@/mixins/frontMixin'

export default {
  mixins: [FrontMixins],
  data() {
    return {
      tableList: [],
      params: {
        pageSize: 10,
        pageNum: 1,
      },
      total: 0,
    }
  },
  computed: {
    ...mapGetters('user', [
      'role',
    ])
  },
  components: {
    MarketDemand
  },
  mounted() {
    this.initSetting()
  },
  methods: {
    async initSetting() {
      const { rows, total } = await getNavBrandList({ ...this.params, category: 2 })
      this.tableList = rows
      this.total = total
    },
    detailClick(item) {
      if (this.authorityManagement()) {
        return
      }
      const a = document.createElement('a')
      a.href = item.file.filePath
      a.download = item.file.fileName
      a.click()
    },
    pageChange(e) {
      this.params.pageNum = e
      this.initDefaultValue()
    },
  },
}
</script>